package ObsoletsButUtil;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import Entitys.Pedido;
import Entitys.ProductoGeneral;
import control_package.BussinesControl;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import services.PedidoServices;

/**
 *
 * @author MAURO
 */
public class OrderGuiOld extends javax.swing.JPanel {
    private BussinesControl ped=new BussinesControl();
    private Pedido pedido=new Pedido();
    private PedidoServices peser=new PedidoServices();
    private String[] labels={"Id", "Nombre de Producto","Precio","Cantidad"};
    private DefaultTableModel tablePed =new DefaultTableModel(labels, 15);
    private DefaultComboBoxModel PedidoComboboxModel=new DefaultComboBoxModel();

    /**
     * Creates new form OrderGui
     */
    public OrderGuiOld() {
        initComponents();
        PedidoComboBoxModelFill();
        this.TablePed.setModel(tablePed);
       
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    
    
    
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PedidojComboBox = new javax.swing.JComboBox();
        jScrollPane2 = new javax.swing.JScrollPane();
        TablePed = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        InfojTextPane = new javax.swing.JTextPane();

        setBorder(javax.swing.BorderFactory.createTitledBorder("PEDIDOS"));
        setAutoscrolls(true);
        setPreferredSize(new java.awt.Dimension(1240, 640));

        PedidojComboBox.setFont(new java.awt.Font("Verdana", 0, 22)); // NOI18N
        PedidojComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        PedidojComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                PedidojComboBoxItemStateChanged(evt);
            }
        });
        PedidojComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PedidojComboBoxActionPerformed(evt);
            }
        });

        TablePed.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(TablePed);

        jButton1.setFont(new java.awt.Font("Verdana", 0, 18)); // NOI18N
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icons/Copia de icon_check.png"))); // NOI18N
        jButton1.setText("TERMINADO");

        InfojTextPane.setFont(new java.awt.Font("Verdana", 0, 24)); // NOI18N
        jScrollPane1.setViewportView(InfojTextPane);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 1218, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(PedidojComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 426, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton1)
                        .addGap(17, 17, 17))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PedidojComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(25, 25, 25))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void PedidojComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PedidojComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_PedidojComboBoxActionPerformed

    private void PedidojComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_PedidojComboBoxItemStateChanged
        String cadena="";
        
         
             pedido= ped.MakeQuery(this.PedidojComboBox.getSelectedItem());   
       
        //aqui falta implementar las Querys para traer el fabricante que está relacionado, otras vainas, y la implementación cuando tenemos un array de productos 
        cadena=" Nombre: "+pedido.getNombreClientePed()+"\n Telefono: "+pedido.getTelefonoClientePed()+
                "\n Direccion: "+ pedido.getDireccionClienPedido()+"\n Hora: " +pedido.getHoraPedido()+"\n Fecha: "+ pedido.getFechaPedido();
        
        this.InfojTextPane.setText(cadena);
   
    
        // TODO add your handling code here:
    }//GEN-LAST:event_PedidojComboBoxItemStateChanged

    public void PedidoComboBoxModelFill(){
           this.PedidoComboboxModel.addElement("Seleccione");
           for(Pedido pedi:peser.readAll()){
           this.PedidoComboboxModel.addElement(pedi.getIdPedido());
           }
     PedidojComboBox.setModel(PedidoComboboxModel);
 }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextPane InfojTextPane;
    private javax.swing.JComboBox PedidojComboBox;
    private javax.swing.JTable TablePed;
    private javax.swing.JButton jButton1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration//GEN-END:variables





}